function YHPoint(x, y){
	this.X = x;
	this.Y = y;
}
function YHLine(point1, point2){
	var Point1 = null;
	var Point2 = null;
	var Defined = false;
	this.setPoints = function(p1, p2){
		Point1 = p1;
		Point2 = p2;
		Defined = Point1 && Point2 && (Point1.X != Point2.X);
		this.UpdateParams();
		return this;
	};
	this.IsDefined = function() {
		return Defined;
	};
	var Active = true;
	this.Activate = function(){
		Active = true;
		return this;
	};
	this.Deactivate = function(){
		Active = false;
		return this;
	};
	this.IsActive = function(){
		return Active && this.IsDefined();
	};
	this.func = function(x){
		return (!this.IsActive()) ? null : (ParamA * x + ParamB);
	};
	var ParamA = 0;
	var ParamB = 0;
	this.UpdateParams = function(){
		if(!this.IsDefined()){
			ParamA = 0;
			ParamB = 0;
		}
		else{
			var delim = (Point1.X - Point2.X);
			ParamA = (Point1.Y - Point2.Y)/delim;
			ParamB = (Point1.X*Point2.Y - Point1.Y*Point2.X)/delim;
		}
		return this;
	};
	this.PositionFor = function(point) {
		if(!this.IsActive() || !point)
			return YHConstants.position.unknown;
		var resultY = this.func(point.X);
		if(resultY < point.Y)
			return YHConstants.position.up;
		else if(resultY == point.Y)
			return YHConstants.position.same;
		else
			return YHConstants.position.down;
	};
	this.LengthTo = function(x, y) {
		if(!x || !y || !this.IsActive())
			return null;
		return this.func(x) - y;
	};
	this.setPoints(point1, point2);
}

function randomText(strings, max1, max2) {
	var stringsLength = strings.length;
	var parCount = getRandom(max1) + 1;
	var i = 0
	var j = 0;
	var resultStr = "";
	while(i++ < parCount)
	{
		var sentCount = getRandom(max2) + 1;
		while(j++ < sentCount)
			resultStr += strings[getRandom(stringsLength)] + " ";
	resultStr += "<br />";
	j = 0;
}
return resultStr;
}
function getRandom(max){
	return Math.floor((Math.random()*max));
}

function isUFloatRegExp(n) {
	var floatRegEx=/^\d+([,\.](\d+)?)?$/gi;
	return (floatRegEx.test(n));
}

function isFloatRegExp(n) {
	var floatRegEx=/^-?\d+([,\.](\d+)?)?$/gi;
	return (floatRegEx.test(n));
}

function isUIntRegEx(n){
	var uintRegEx=/^\d+$/g;
	return (uintRegEx.test(n));
}